﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AutoFacUtils;
using CashFlow.Web.Service;
using IShopUserService2 = CashFlow.Web.Areas.ShopManage.Service.IShopUserService;

namespace CashFlow.Web.Areas.ShopManage.Validator
{
    public class CommonValidator
    {
        private static IUserService GetUserService() { return AutoFacHelper.Get<IUserService>(); }
        private static IShopUserService GetShopUserService() { return AutoFacHelper.Get<IShopUserService>(); }
        private static IShopUserService2 GethopUserService2() { return AutoFacHelper.Get<IShopUserService2>(); }

        public static bool IsUserInShop(int userId)
        {
            var userService = GetUserService();
            var ui = userService.GetLoginShopInfo();
            var shopUserService2 = GethopUserService2();
            var count = shopUserService2.Count(x => x.UserId == userId
                            && x.ShopManagerUserId == ui.ShopManagerUserId
                        );
            return count > 0;
        }
    }
}